﻿@using ZoomLa.BLL
@model ZoomLa.Model.M_Message
@{
    B_User buser = new B_User();
}
@section head{
    <title>发送短消息</title>
}
@section content{
    <div id="pageflag" data-nav="index" data-ban="pub"></div>
    <div class="container margin_t5">
        <ol class="breadcrumb">
            <li><a title="会员中心" href="@Url.Action("Default","")">会员中心</a></li>
            <li><a href="@Url.Action("Message", "Message")">消息中心</a></li>
            <li class="active">发送短消息</li>
        </ol>
    </div>
    <div class="container">
        @Html.Partial("MessageTop")
        <form method="post" id="msgForm">
            <div class="us_seta btn_green" style="margin-top:5px;">
            <table class="table_li table-border">
                <tr>
                    <td class="text-right td_m">收件人</td>
                    <td class="tdRight">
                        <div class="input-group" style="width: 380px;">
                            <input type="text" class="form-control text_300" id="refer_t" name="refer_t" value="@buser.GetUserNameByIDS(Model.Incept)" />
                            <input type="hidden" id="refer_hid" name="refer_hid" value="@Model.Incept"/>
                            <span class="input-group-btn">
                                <button type="button" onclick="zlmsg.selUser('refer')" class="btn btn-primary">选择用户</button>
                            </span>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="text-right">抄送人</td>
                    <td class="tdRight">
                        <div class="input-group" style="width: 380px;">
                            <input type="text" id="ccuser_t" name="ccuser_t" class="form-control text_300" value="@buser.GetUserNameByIDS(Model.CCUser)">
                            <span class="input-group-btn">
                                <button type="button" onclick="zlmsg.selUser('ccuser')" class="btn btn-primary">选择用户</button>
                            </span>
                        </div>
                        <input type="hidden" id="ccuser_hid" name="ccuser_hid" value="@Model.CCUser" />
                    </td>
                </tr>
                <tr>
                    <td class="text-right">邮件标题</td>
                    <td class="tdRight">
                        <input type="text" id="title_t" name="title_t" class="form-control text_300" value="@Model.Title"/>
                    </td>
                </tr>
                <tr>
                    <td class="text-right">内容</td>
                    <td>
                        <textarea id="content_t" name="content_t" style="height:240px;width:100%;">@Model.Content</textarea>
                    </td>
                </tr>
                <tr id="hasFileTR">
                    <td class="text-right">
                        已上传文件<input type="hidden" id="hasfiledata" />
                    </td>
                    <td id="hasFileTD"></td>
                </tr>
                <tr>
                    <td class="text-right">附件</td>
                    <td>
                        <input type="button" id="upfile_btn" class="btn btn-primary" value="选择文件" />
                        <div style="margin-top: 10px;" id="uploader" class="uploader">
                            <ul class="filelist"></ul>
                        </div>
                        <input type="hidden" id="Attach_Hid" name="Attach_Hid" value="@Model.Attachment"/>
                    </td>
                </tr>
                <tr>
                    <td></td>
                    <td>
                        <button type="button" onclick="zlmsg.send('Message_Add?id=@Request["ID"]');" class="btn btn-primary">发送邮件</button>
                        <button type="button" onclick="zlmsg.send('Message_Draft?id=@Request["ID"]');" class="btn btn-primary">存为草稿</button>
                    </td>
                </tr>
            </table>
        </div>
        </form>
        <div class="alert alert-success">
            <i class="fa fa-lightbulb-o"></i>
            提示：系统支持以MessageSend?uid=[用户ID]&content=[内容]方式get将站内信发送,如:MessageSend?name=admin&content=站内信
        </div>
    </div>

}
@section script{

<link href="/JS/Controls/ZL_Webup.css" rel="stylesheet" />
<script src="/Plugins/Ueditor/ueditor.config.js" charset="utf-8"></script>
<script src="/Plugins/Ueditor/ueditor.all.min.js" charset="utf-8"></script>
<script src="/JS/Controls/ZL_Dialog.js"></script>
<script src="/JS/Controls/ZL_Webup.js"></script>
@MvcHtmlString.Create(Call.GetUEditor("content_t", 2))
    <script>
        var zlmsg = { diag: null };
        zlmsg.init = function () {
            user.hook[zlmsg.conast.CCUser] = function (list, select) {
                $("#ccuser_t").val(user.getnames(list));
                $("#ccuser_hid").val(user.getids(list));
                zlmsg.diag.CloseModal();
            }
            user.hook[zlmsg.conast.Refer] = function (list, select) {
                $("#refer_t").val(user.getnames(list));
                $("#refer_hid").val(user.getids(list));
                zlmsg.diag.CloseModal();
            }
        }
        zlmsg.conast = { CCUser: "ccuser", Refer: "refer" };
        zlmsg.selUser = function (action) {
            if (!zlmsg.diag) {
                zlmsg.diag = new ZL_Dialog();
                zlmsg.diag.maxbtn = false;
            }
            switch (action) {
                case zlmsg.conast.CCUser:
                    zlmsg.diag.title = "选择抄送人";
                    zlmsg.diag.url = "/Common/Dialog/SelGroup.aspx#" + zlmsg.conast.CCUser;
                    break;
                case zlmsg.conast.Refer:
                default:
                    zlmsg.diag.url = "/Common/Dialog/SelGroup.aspx#" + zlmsg.conast.Refer;
                    zlmsg.diag.title = "选择收件人";
                    break;
            }
            zlmsg.diag.ShowModal();
        }
        zlmsg.subCheck = function () {
            var refer = $("#refer_hid").val();
            var title = $("#title_t").val();
            var content = UE.getEditor("content_t").getContentTxt();
            if (ZL_Regex.isEmpty(refer)) { alert("未选定收件人"); return false; }
            if (ZL_Regex.isEmpty(title)) { alert("标题不能为空"); return false; }
            if (ZL_Regex.isEmpty(content)) { alert("内容不能为空"); return false; }
            return true;
        }
        zlmsg.send = function (url) {
            if (zlmsg.subCheck() == false) { return false; }
            mvcpage.help.submit({ formid: "msgForm", "url": url });
        }
        $(function () {
            $("#upfile_btn").click(ZL_Webup.ShowFileUP);
            ZL_Webup.AddReadOnlyLi($("#Attach_Hid").val());
            zlmsg.init();
        })
        function AddAttach(file, ret, pval) { return ZL_Webup.AddAttach(file, ret, pval); }
    </script>
}
